﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using ZX.Report;
using ZX.BLL.Extend;
using ZX.SYS.Library;
using ZX.DBModule;
using ZX.Web.UI.Controls;

namespace ZX.WebApp.Extend.Reports
{
    public partial class listReportTest : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string deptId = GetStringFromQueryString("deptId", string.Empty);
                string year = GetStringFromQueryString("year", string.Empty);
                string month = GetStringFromQueryString("month", string.Empty);
                SysReportQueryParameter rpQueryParam = new SysReportQueryParameter();
                BaseBussnies bll = new BaseBussnies();
                DataTable dt = null;
                DataSet dataSources = new DataSet();
                string sql = "exec sp_GetMonthYeByDeptId '" + deptId + "','" + year + "','" + month + "'";
                dt = bll.GetDataBySqlComm(sql);
                DataTable source = dt.Copy();
                source.TableName = "set";
                dataSources.Tables.Add(source);
                ListParams paramsFactory = (ListParams)ParamsFactory.GetInstance(ReportType.List, dataSources);

                ReportFactory reportFactory = ReportFactory.GetInstance(paramsFactory);
                this.ReportViewer.Report = reportFactory.GetReport();
            }
            catch (Exception ex)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script language='javascript'>alert('生成报表出现错误:" + ex.Message + "');</script>");
            }
        }
    }
}
